<!-- 假种 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="my" uri="http://www.trkj.com/tr1702/tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>假种</title>
</head>
<body>
		<!-- 按钮 -->
		<div id="hjj-bt-holidayType" style="padding: 5px; height:auto">
			<!-- 添加 -->
			<my:g id="54"><a id="hjj-bt-holidayType-insert" href="JavaScript:holidayTypeAdd();" class="easyui-linkbutton hjj-add-holidayType" data-options="iconCls:'icon-add',text:'新增'"></a></my:g>
			
			<a id="hjj-holiday-reload" class="easyui-linkbutton" data-options="iconCls:'icon-reload'"></a>
			
			
			搜索文本	<a class="easyui-textbox" data-options="width:200" id="holiday-text"></a>
			<a class="easyui-linkbutton" data-options="iconCls:'icon-search',text:'搜索'" id="holiday-search"></a>
		</div>
	<table  class="easyui-datagrid"  id="hjj-holiday-dg"
        data-options="
        fitColumns:true,
        fit:true,
        border:false,
        singleSelect:true,
        autoRowHeight:true,
         <!-- 分页 -->
		pagination:true,
		<!-- ulr: -->
		url:'to_isholiday',
		method:'get',
		pageSize:5,
		pageList:[5,10,15,20],
		pagePosition:'bottom',
		toolbar: '#hjj-bt-holidayType'
		
        "
		>   
    <thead>   
        <tr>   
        
            <th data-options="field:'HOLIDAY_ID',width:100" align="center">编码</th>   
            <th data-options="field:'HOLIDAY_NAME',width:100" align="center">名称</th>
			<th data-options="field:'HOLIDAY_SALARY',width:100" align="center">薪资处理</th>
			<th data-options="field:'HOLIDAY_PERSONAL',width:80,formatter:isholiday" align="center">假种</th>
			<th data-options="field:'HOLIDAY_LEGAL',width:80,formatter:isfaholiday" align="center">法定假</th>
			<th data-options="field:'HOLIDAY_REMARKS',width:120" >备注</th>
			<th data-options="field:'HOLIDAY_PERSON',width:80">创建人</th>
			<th data-options="field:'HOLIDAY_FOUNDDATE',width:100,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}">创建时间</th>
			<th data-options="field:'HOLIDAY_UPDATE',width:100,formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}">更新时间</th>
			<th data-options="field:'HOLIDAY_TYPE',width:30,formatter:what_holiday"align="center">关闭</th>
			<th data-options="field:'other',width:90,formatter:holidayformatter" align="center"></th>
			</tr>   
			
    </thead>   
	</table>  	
	 <script type="text/javascript">
	 //法定假
	 var isfaholiday= function(value,row,index){
		 isfa="";
		 var isfaho=row.HOLIDAY_LEGAL;
		 if(isfaho==0){
			 isfa= "<input type='checkbox' disabled='disabled'>";
		 }else if(isfaho==1){
			 isfa="<input type='checkbox' checked disabled='disabled'>"; 
		 }
		 return isfa;
	 }
	 //假种
	 var isholiday = function(value,row,index){
		 var hol="";
		 var isho = row.HOLIDAY_PERSONAL;
		 if(isho=="否"){
			 hol = "<input type='checkbox' disabled='disabled'>";
		 }else if(isho="是"){
			 hol="<input type='checkbox' checked disabled='disabled'>"; 
		 }
		 return hol;
	 }
	 var what_holiday= function(value,row,index){
			var pic="";
			var state = row.HOLIDAY_TYPE;
			if(state==0){
				pic = "<input type='checkbox' disabled='disabled'>";
			}else if(state==1){
				pic="<input type='checkbox' checked disabled='disabled'>";
			}
			return pic;
		}
	 /*  编辑按钮 */
	   function holidayformatter(value, row, index){
		   var block =""; 
		   var edit ="";
		   var remove ="";
		  	<my:g id="55">block = "<a  onclick='toBlock(" + row.HOLIDAY_ID + ","+row.HOLIDAY_TYPE+")' class='cell_btn_block' href='#'></a>";</my:g>
		   
		  	<my:g id="56"> edit = "<a  onclick='toEditRole(" + row.HOLIDAY_ID + ")' class='cell_btn_edit' href='#'></a>";</my:g>
               
		  	<my:g id="57">remove = "<a  onclick='deleteRole(" + row.HOLIDAY_ID +")' class='cell_btn_del' href='#'></a>";</my:g>

           return block + edit + remove ;

       };
	  /*  编辑按钮图标 */
	 	$(function(){
	 		$("#hjj-holiday-dg").datagrid({onLoadSuccess: function(){
				$(".cell_btn_block").linkbutton({iconCls:'icon-changes', plain:true});
				$(".cell_btn_edit").linkbutton({iconCls:'icon-update_red', plain:true});
				$(".cell_btn_del").linkbutton({iconCls:'icon-delete_red', plain:true});
			}});
			
	 	})
	 	/*新增*/
	 	function holidayTypeAdd(){
					$('#hjj-holidayType-dlg1').dialog('open').dialog('center');
		}
	 	//刷新
		$("#hjj-holiday-reload").linkbutton({
			onClick:function(){
				$('#hjj-holiday-dg').datagrid('reload');
			}
		});	
	 	/* 删除 */
		var deleteRole= function(Id){
			$('#hjj-holidayType-dlg-edit').dialog("close");
			$.messager.confirm('确认','您确认要删除假种吗？',function(v){
				if(v){
					$.post("delete_holiday_",{holidayId:Id},function(v){
						if(v.success){
							$('#hjj-holiday-dg').datagrid('reload');
						}else{
							$.messager.alert('错误',v.message);
						}
					});
				}else{
					
				}
				
			});
		}
		/*禁用*/
		var toBlock =function(id,State){
			$('#hjj-holidayType-dlg-edit').dialog("close");
			var jy_state =1;
			if(State==1){
				jy_state=0;
				$.messager.confirm('确认', '您确定要打开该假种吗？', function(v){
					if(v){
						$.post("update_holidaystate", {holidayId: id,holidayType:jy_state}, function(v){
							if(v.success){
								$('#hjj-holiday-dg').datagrid('reload');
							}else{
								$.messager.alert('错误', v.message);
							}
						});
					}else{
						
					}
					
				}); 
			}else if(State==0){
				jy_state=1;
				$.messager.confirm('确认', '您确定要关闭该假种吗？', function(v){
					if(v){
						$.post("update_holidaystate", {holidayId: id,holidayType:jy_state}, function(v){
							if(v.success){
								$('#hjj-holiday-dg').datagrid('reload');
							}else{
								$.messager.alert('错误', v.message);
							}
						});
					}else{
						
					}
					
				}); 
			}
		}
	  	/* 编辑 */
	  	function toEditRole(id){
	  		$('#hjj-holidayType-ff-edit').form('load','load_holiday?holidayId='+id);
	  		$('#hjj-holidayType-dlg-edit').dialog('open');
	  		
	  	}
	  	//双击编辑
	  	//双击修改
			<my:g id="56">$('#hjj-holiday-dg').datagrid({
				onDblClickRow: function(index, row){
					$('#hjj-holidayType-dlg-edit').dialog("open");
					$('#hjj-holidayType-ff-edit').form('load','load_holiday?holidayId='+row.HOLIDAY_ID);
				}
			});
			</my:g>
	  //模糊搜索
		$("#holiday-search").linkbutton({
			onClick:function(){
				var SeeText = $("#holiday-text").textbox("getText");
				 $("#hjj-holiday-dg").datagrid({url:'to_isholidayByName?holidayName='+SeeText,method:'get'});
				$("#hjj-holiday-dg").datagrid("reload"); 
			}
		});
	 </script>
	<!--  新增 -->
	<div id="hjj-holidayType-dlg1" class="easyui-dialog" style="padding:20px 20px;width:450px;"
	 data-options="inline:true,modal:true,closed:true,title:'新增假种',iconCls:'icon-save',
		buttons:[{
					text:'保存',
					iconCls:'icon-add',
					handler:function(){
						<!-- 提交 -->
						$('#hjj-holidayType-ff').form('submit', {    
						      url:'is_add_holidayss',
						      method:'post',
						    onSubmit: function(param){   
						    	param['holidayName']= $('#holidaytypeName').textbox('getText');
						    	param['holidaySalary']=$('.holidaytypeIsemolument').val();
						    	if($('#isfaholiday').is(':checked')){
								param['holidayLegal']=parseInt(1);
								}else{
									param['holidayLegal']=parseInt(0);
								}
								if($('#isholidays').is(':checked')){
								param['holidayPersonal']='是';
								}else{
									param['holidayPersonal']='否';
								}
								if($('#isholidaystop').is(':checked')){
								param['holidayType']=parseInt(1);
								}else{
									param['holidayType']=parseInt(0);
								}
								param['holidayRemarks']=$('#holidayremake').textbox('getText');
						       return $('#hjj-holidayType-dlg1').form('validate');
						    },    
						    success:function(v){   
						    
						      if(v){
						      $('#hjj-holidayType-dlg1').dialog('close')
						      $('#hjj-holidayType-ff').form('clear')
						      $('#hjj-holiday-dg').datagrid('reload')
						     }else{
						     	$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
						     }
						    }    
						});  
												
					
					}
				},{
					text:'关闭',
					iconCls:'icon-cancel',
					handler:function(){
						$('#hjj-holidayType-dlg1').dialog('close')
					}
				}]
				
				
		">
		<form id="hjj-holidayType-ff"  method="post">
	
			<div style="margin-bottom:10px">
				<input id="holidaytypeName" class="easyui-textbox" data-options="label:'名称：',required:true"  prompt="请输入" style="width:80%;height:25px">
			</div>
			<div style="margin-bottom:10px">
				<select id="hjj-cc-holidayType" class="easyui-combobox holidaytypeIsemolument" data-options="label:'薪资处理：',panelHeight:'auto'"  style="width:80%;">   
   					 	<option value="有薪">有薪</option>   
  						<option value="无薪">无薪</option>   
				</select>  
			</div>
			
			
			<div style="margin-bottom:10px">
				<label >假种：</label>
				&nbsp&nbsp
				&nbsp&nbsp
				
				法定假：
				<input type="checkbox"value="0" id="isfaholiday"/>
				&nbsp&nbsp
				个人假种：
				<input type="checkbox"value="0" id="isholidays"/>
				&nbsp&nbsp
				
				停用:
				<input type="checkbox" value="停用"id="isholidaystop"/>
			</div>
			
			<div>
				<input class="easyui-textbox" data-options="label:'备注：',multiline:true,height:100,width:'90%'" id="holidayremake"/>
			</div>
		</form>	
	</div>
	
	<!-- 编辑 -->
	<div id="hjj-holidayType-dlg-edit" class="easyui-dialog" style="padding:20px 20px;width:450px;"
	 data-options="inline:true,modal:true,closed:true,title:'编辑假种',iconCls:'icon-save', 
		buttons:[{
					text:'保存',
					iconCls:'icon-ok',
					handler:function(){
						<!-- 提交 -->
						$('#up-holiday').form('submit', {    
						    url:'is_update_holiday',
						    onSubmit: function(param){    
						    	param['holidayId']=$('#holidayIds').textbox('getText');
						      	param['holidayName']= $('#holidaytypeNames').textbox('getText');
						    	param['holidaySalary']=$('.holidaytypeIsemoluments').val();
						    	param['holidayRemarks']=$('#holidayremakes').textbox('getText');
						    	if($('#isfaholidays').is(':checked')){
								param['holidayLegal']=parseInt(1);
								}else{
									param['holidayLegal']=parseInt(0);
								}
								if($('#isholidayss').is(':checked')){
								param['holidayPersonal']='是';
								}else{
									param['holidayPersonal']='否';
								}
								if($('#isholidaystops').is(':checked')){
								param['holidayType']=parseInt(1);
								}else{
									param['holidayType']=parseInt(0);
								}
								
						       return $(this).form('validate');
						    },    
						    success:function(v){    
						      <!-- 提交关闭 -->  
						      if(v){
						      $('#hjj-holidayType-dlg-edit').dialog('close')
						      $('#hjj-holidayType-ff-edit').form('clear')
						      $('#hjj-holiday-dg').datagrid('reload')
						      }else{
						      		$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
						      }
						    }    
						});  
												
					
					}
				},{
					text:'关闭',
					iconCls:'icon-cancel',
					handler:function(){
						$('#hjj-holidayType-dlg-edit').dialog('close')
					}
				}]
				
				
		">
		<form id="hjj-holidayType-ff-edit"  method="get">
			<!-- 隐藏ID -->
			<input type="hidden" class="easyui-textbox" id="holidayIds" name="holidayId">
			
			<div style="margin-bottom:10px">
				<input  id="holidaytypeNames" name="holidayName" class="easyui-textbox" data-options="label:'名称：'"  prompt="请输入" style="width:80%;height:25px">
			</div>
			<div style="margin-bottom:10px">
				<select id="hjj-cc-holidayType" class="easyui-combobox holidaytypeIsemoluments" data-options="label:'薪资处理：',panelHeight:'auto'" name="holidaySalary" style="width:80%;">   
   					 	<option value="有薪">有薪</option>   
  						<option value="无薪">无薪</option>
				</select>  
			</div>
			
			
			<div style="margin-bottom:10px">
				<label >假种：</label>
				&nbsp&nbsp
				&nbsp&nbsp
				
				法定假：
				<input type="checkbox"value="1" id="isfaholidays" name="holidayLegal"/>
				&nbsp&nbsp
				个人假种：
				<input type="checkbox"value="是" id="isholidayss" name="holidayPersonal"/>
				&nbsp&nbsp
				停用:
				<input type="checkbox" value="1" id="isholidaystops" name="holidayType"/>
			</div>
			
			<div>
				<input id="holidayremakes" name="holidayRemarks" class="easyui-textbox " data-options="label:'备注：',multiline:true,height:100,width:'90%'" />
			</div>
		</form>	
	</div>
	<div>
		<form method="post" id="up-holiday"></form>
	</div>
</body>
</html>